\documentclass[10pt,a4paper]{report}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{CJK}
\begin{document}
\title{Parallel Computing, Assignment 1}
\author{Yang Huang}
\maketitle

In our implementation, we put the n body along unit circle, with the velocity pointing to the origin.
We tested the result with different n from 100 to 5000, the results are shown below.
Version 1 indicates the result for my initial implementation  while version 2 is the one I modified my adjustment.
The main improvement was initially, I computed $f_ij$ for all $i,j$ and stored them, then I computed the $F_i$ for each
$i$ with another double loop. Later I realized that the second double loop was unnecessary, I could compute $F_i$ when I 
compute $f_ij$ and $f_ij$ do not need to be stored. This not only save me almost half the time it takes, but also reduced
the space needed from $O(n^2)$ to $O(n)$.
I use function clock() to get the run time and set $iteration=100$ to get an reasonable result. For large $n$, fewer loops
is ok, but for $n=100$, due to the limit of function clock(), we cannot get $t_{iter}$. To make the analysis consist, we use
the same iteration for all different data size.

\begin{figure}
	\centering
	\subfigure{
		\includegraphics[scale=0.5]{code_v1.png}
		\label{fig:subfig:a}
		}
	\hspace{0.5in}
	\subfigure{
		\includegraphics[scale=0.5]{code_v2.png}
		\label{fig:subfig:b}
		}
	\label{fig:code}
	\caption{code}
\end{figure}

\begin{figure}
\begin{center}
\includegraphics[scale=0.5]{titer.png}
\caption{time in second per iteration for different n}
\end{center}
\end{figure}


\begin{figure}
\begin{center}
\includegraphics[scale=0.5]{n2overtiter.png}
\caption{$\frac{n^2}{t_{iter}}$ for different n}
\end{center}
\end{figure}
We can see that $\frac{n^2}{t_{iter}}$ is approximately $2*10^7$ for version 1 and $3.7*10^7$ for version 2, version 2 is 
almost 2 times faster.

\end{document}